/*
 * UniMediaSource.cpp
 *
 *  Created on: 2020年3月30日
 *      Author: chuanjiang.zh
 */

#include "UniMediaSource.h"
#include "UMediaReaderSource.h"
#include "UniMediaReader.h"


DLLEXPORT UMediaSource* umedia_createSource(const char* url)
{
	return new UMediaReaderSource();
}

DLLEXPORT void umedia_destroySource(UMediaSource* source)
{
	if (source)
	{
		source->close();

		delete source;
	}
}



void UniMediaSource::startup()
{
	UniMediaReader::startup();
}

void UniMediaSource::cleanup()
{
	UniMediaReader::cleanup();
}



UMediaSource* UniMediaSource::create(const char* url)
{
	return umedia_createSource(url);
}

void UniMediaSource::destroy(UMediaSource* source)
{
	umedia_destroySource(source);
}

UMediaSource* UniMediaSource::create(const char* url, int loopCount)
{
	UMediaReaderSource* source = new UMediaReaderSource();
	source->setLoopCount(loopCount);
	return source;
}

void UniMediaSource::setRetryTime(UMediaSource* source, int ms)
{
	UMediaReaderSource* readerSource = dynamic_cast<UMediaReaderSource*>(source);
	if (readerSource)
	{
		readerSource->setRetryTime(ms);
	}
}

void UniMediaSource::setStackSize(int size)
{
	if (size <= 0)
	{
		return;
	}

	UMediaReaderSource::STACK_SIZE = size;
}